<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>闭包</title>
</head>
<body>

</body>
<script>
    // 当内部函数被保存到外部时,将会生成闭包. 闭包会导致原有作用域链不释放,造成内存泄露

    function a() {
        function b () {
            var bbb = 234;
            console.log(aaa);
        }
        var aaa = 123;
        return b;
    }
    var glob = 100;
    var demo = a();
    demo();
</script>
</html>
